{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style>
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0;
        margin-top: 0
    }

    #title span {
        float: right;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='1'}asdlkjasd{/eq}{else /}asdlkjasd{/present}" href="{:url('index',['types'=>1])}{present name='status'}/status/{$status}{/present}">头像</a>
                        <!-- <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='2'}asdlkjasd{/eq}{/present}" href="{:url('index',['types'=>2])}{present name='status'}/status/{$status}{/present}">微信</a> -->
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='3'}asdlkjasd{/eq}{/present}" href="{:url('index',['types'=>3])}{present name='status'}/status/{$status}{/present}">昵称</a>
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='4'}asdlkjasd{/eq}{/present}" href="{:url('index',['types'=>4])}{present name='status'}/status/{$status}{/present}">个性签名</a>
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='6'}asdlkjasd{/eq}{/present}" href="{:url('index',['types'=>6])}{present name='status'}/status/{$status}{/present}">自我介绍</a>
                        <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='7'}asdlkjasd{/eq}{/present}" href="{:url('index',['types'=>7])}{present name='status'}/status/{$status}{/present}">背景图</a>
                        <!-- <a class="btn btn-default btn-outline {present name='types'}{eq name='types' value='5'}asdlkjasd{/eq}{/present}" href="{:url('index',['types'=>5])}{present name='status'}/status/{$status}{/present}">相册</a> -->
                    </div>
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='0'}asdlkjasd{/eq}{else /}asdlkjasd{/present}" href="{:url('index',['status' => 0])}{present name='types'}/types/{$types}{/present}">审核</a>
                        <a class="btn btn-default btn-outline {eq name='status' value='1'}asdlkjasd{/eq}" href="{:url('index',['status' => 1])}{present name='types'}/types/{$types}{/present}{present name='extra'}/extra/{$extra}{/present}">通过</a>
                        <a class="btn btn-default btn-outline {eq name='status' value='-1'}asdlkjasd{/eq}" href="{:url('index',['status' => -1])}{present name='types'}/types/{$types}{/present}{present name='extra'}/extra/{$extra}{/present}">拒绝</a>
                    </div>
                    {present name='types'}
                    {eq name='types' value='1'}
                    <div class="fixed-table-toolbar" style="display: flex;">
                        <a class="btn btn-default btn-outline {eq name='extra' value='0'}asdlkjasd{/eq}" href="{:url('index',['extra'=>'0'])}{present name='status'}/status/{$status}{/present}">全部</a> 
                        <a class="btn btn-default btn-outline {eq name='extra' value='1'}asdlkjasd{/eq}" href="{:url('index',['extra'=>'1'])}{present name='status'}/status/{$status}{/present}">真人</a>
                    </div>
                    {/eq}
                    {/present}
                    <div style="display:block;clear: both;"></div>
                    <div class="fixed-table-toolbar">
                        <form  method="get" action="" style="display: flex;">
                            <div class="pull-left search" style="display: flex;">
                                <div class="columns columns-right btn-group pull-left">
                                    <select class="form-control" name="search">
                                        <option value="id" {php}if(input('?param.search')){if(input('param.search')=='id'){echo "selected";} }{/php}>会员ID</option>
                                        <option value="name" {php}if(input('?param.search')){if(input('param.search')=='name'){echo "selected";} }{/php}>昵称</option>
                                    </select>
                                </div>
                                <div class="pull-right search">
                                    <input class="form-control input-outline" type="text"
                                           {php}
                                           if(input('?param.name')){
                                    if(input('param.name')){
                                    echo "value='".input('name')."'";
                                    }

                                    }
                                    {/php}
                                    name="name" placeholder="搜索">
                                </div>

                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" type="submit">搜索</button>
                                </div>

                                {php}
                                if(input('?param.name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('index')}">返回管理</a>
                                </div>{php}
                                }
                                {/php}
                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                            <table data-toggle="table">
                                <thead>
                                <tr>
                                  <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">类型</th>
                                    <th data-align="center">用户</th>
                                    <th data-align="center">内容</th>
                    {present name='types'}
                    {eq name='types' value='1'}
                                    <th data-align="center">真人</th>
                    {/eq}
                    {/present}
                                    {eq name='$types' value='2'}
                                    <th data-align="center">二维码</th>
                                    {/eq}
                                    <th data-align="center">提交时间</th>
                                    <th data-align="center">更新时间</th>
                                    <th data-align="center">审核时间</th>
                                    <th data-align="center">审核人</th>

                                    <th data-align="center">管理</th>
                                </tr>
                                </thead>
                                <tbody id="form">
                                {php}$hide=array('0'=>'<font color="#f00">禁止</font>','1'=>'<font color="#1ab394">正常</font>','2'=>'审核','3'=>'<font color="#f00">拒绝</font>');{/php}
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.id}"></td>
                                    <td>{$v.id}</td>
                                    <td>
                                        {switch name="v.types"}
                                            {case value="1"}头像{/case}
                                            {case value="2"}微信{/case}
                                            {case value="4"}签名{/case}
                                            {case value="6"}介绍{/case}
                                            {case value="7"}背景图{/case}
                                            {default /}昵称
                                        {/switch}
                                    </td>
                                    <td><a onclick="member('{$v.user_id}')" style="color:#40BCF7">{$v.name}</a><br/>
                                        ({$v.sex})({$v.age}岁)({$v.user_id})
                                        {if condition="in_array($v.types, [4,6])"}
                                        【{$v.entertainment_text}】
                                        {/if}
                                    </td>
                                    <td>
                                        {switch name="v.types"}
                                            {case value="1"}
											<!-- ... 已有代码 ... -->
											{php}
											// 检查 $v.content 是否存在且不为空
											if (isset($v['content']) && $v['content'] !== '') {
											    // 判断 URL 是否包含协议头
											    $noHttp = strpos($v['content'], 'http://') === false && strpos($v['content'], 'https://') === false;
											    $contentUrl = $noHttp ? '__ROOT__' . $v['content'] : $v['content'];
											    // 对 URL 进行转义处理
											    $escapedContentUrl = htmlspecialchars($contentUrl, ENT_QUOTES, 'UTF-8');
											} else {
											    $escapedContentUrl = '';
											}
											{/php}
											{if condition="$escapedContentUrl"}
											<a onclick="lookBigImg('{$escapedContentUrl}')" href="{$escapedContentUrl}" target="_blank">
											    <img style="max-width:100px" src="{$escapedContentUrl}"/>
											</a>
											{/if}
											<!-- ... 已有代码 ... -->
                                           <!-- {php}
                                            $noHttp = strpos($v['content'], 'http://') === false && strpos($v['content'], 'https://') === false;
                                            {/php}
                                                <a onclick="lookBigImg('{php} if ($noHttp) {echo '__ROOT__';} {/php}{$v.content}')" href="{php} if ($noHttp) {echo '__ROOT__';} {/php}{$v.content}" target="_blank"><img style="max-width:100px" src="{php} if ($noHttp) {echo '__ROOT__';} {/php}{$v.content}"/></a> -->

                                                {if condition="isset($v.authpic) && $v.authpic"}
                                                {php}
                                                $noHttp = strpos($v['authpic'], 'http://') === false && strpos($v['authpic'], 'https://') === false;
                                                $authpic = $v['authpic'];
                                                if ($noHttp) {
                                                    $authpic = '__ROOT__'.$v['authpic'];
                                                }
                                                {/php}
                                                <a href="{$authpic}" title="{$authpic}" target="_blank" onclick="lookBigImg('{$authpic}')">
                                                    <img style="max-width:100px" src="{$authpic}"/>
                                                </a>
                                                {/if}
                                            {/case}
											<!-- ... 已有代码 ... -->
											{case value="7"}
											{php}
											// 检查 $v.content 是否存在且不为空
											if (isset($v['content']) && $v['content'] !== '') {
											    // 判断 URL 是否包含协议头
											    $noHttp = strpos($v['content'], 'http://') === false && strpos($v['content'], 'https://') === false;
											    $contentUrl = $noHttp ? '__ROOT__' . $v['content'] : $v['content'];
											    // 对 URL 进行转义处理
											    $escapedContentUrl = htmlspecialchars($contentUrl, ENT_QUOTES, 'UTF-8');
											} else {
											    $escapedContentUrl = '';
											}
											{/php}
											{if condition="$escapedContentUrl"}
											<a onclick="lookBigImg('{$escapedContentUrl}')" href="{$escapedContentUrl}" target="_blank">
											    <img style="max-width:100px" src="{$escapedContentUrl}"/>
											</a>
											{/if}
											{/case}
											<!-- ... 已有代码 ... -->
                                           <!-- {case value="7"}
                                            {php}
                                            $noHttp = strpos($v['content'], 'http://') === false && strpos($v['content'], 'https://') === false;
                                            {/php}
                                                <a onclick="lookBigImg('{php} if ($noHttp) {echo '__ROOT__';} {/php}{$v.content}')" href="{php} if ($noHttp) {echo '__ROOT__';} {/php}{$v.content}" target="_blank">
													<img style="max-width:100px" src="{php} if ($noHttp) {echo '__ROOT__';} {/php}{$v.content}"/>
													</a>
                                            {/case} -->
                                            {case value="5"}
                                                <a onclick="watch('{$v.id}')">
                                                    <span class="label label-danger">预览</span>
                                                </a>
                                            {/case}
                                            {default /}{$v.content}
                                        {/switch}
                                    </td>
                    {present name='types'}
                    {eq name='types' value='1'}
                                    <td id="real{$v.id}">
                                        {if condition="$v.extra == 1"}
                                        <span class="btn btn-xs btn-danger">真人</span>
                                        <!-- <span class="btn btn-xs btn-danger" onclick="setRealFace('{$v.id}', 0)">取消真人</span> -->
                                        {else /}
                                        <span class="btn btn-xs btn-primary">普通</span>
                                        <!-- <span class="btn btn-xs btn-primary" onclick="setRealFace('{$v.id}', 1)">设置真人</span> -->
                                        {/if}
                                    </td>
                    {/eq}
                    {/present}
                                    {eq name='$types' value='2'}
                                        <td>
                                            {if condition='$v.extra'}
                                            <a href="__ROOT__{$v.extra}" target="_blank"><img style="max-width:100px" src="__ROOT__{$v.extra}"/></a>
                                            {/if}
                                        </td>
                                    {/eq}
                                    <td> 
                                        <span {php}if(date('Y-m-d')==date('Y-m-d', $v['create_time']))echo 'style="color: #ed5565"';{/php}>
                                            {:date('Y-m-d H:i', $v.create_time)}
                                        </span>
                                    </td>
                                    <td> 
                                        <span {php}if(date('Y-m-d')==date('Y-m-d', $v['update_time']))echo 'style="color: #ed5565"';{/php}>
                                            {neq name="$v.update_time" value="0"}{:date('Y-m-d H:i', $v.update_time)}{/neq}
                                        </span>
                                    </td>
                                    <td>
                                        <span>{neq name="$v.shenhe_time" value="0"}{:date('Y-m-d H:i:s', $v.shenhe_time)}{/neq}</span>
                                    </td>
                                    <td>
                                        <span>{:_getAdminName($v.shenhe_admin_id)}</span>
                                    </td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                {switch name="$v.status"}
                                                    {case value="0"}
                                                        <li><a onClick="shenhe({$v.id},1)">通过</a></li>
                                                        <li class="divider"></li>
                                                        <li><a onClick="shenhe({$v.id},-1)">拒绝</a></li>
                                                        <li class="divider"></li>
                                                    {/case}
                                                {/switch}
                                                <li><a onclick="del('{$v.id}')" style="color: red">删除</a></li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
            <hr>
            <div class="row row-lg">
               <div class="col-sm-6">
                    <div class="btn btn-outline btn-default" onclick="alla(1)">
                        批量通过
                    </div>
                    {present name='types'}{neq name='types' value='3'}
                    <div  class="btn btn-outline btn-default" onclick="alla(-1)">
                        批量拒绝
                    </div>
                    {/neq}{/present}
                </div> 
                <div class="col-sm-12 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}

<script type="text/javascript">

$(document).ready(function(){
    $('#delidAll').click(function(){
        $('input[type=checkbox]').each(function(){
            var self=$(this);
            if(!self.prop('checked')){
                self.prop('checked',true);
            }else{
                self.prop('checked',false);
            }
        });
    })
});
    function shenhe(id, value){

        var remark = '';

        if (value === -1) {
            // layer.prompt({title: '拒绝理由', formType: 2}, function(text, index){
            //     layer.close(index);
            //     remark = text;

            //     ajaxFun("post","{:url('update')}",{id:id,status:value,remark:remark},'json',function(ret){
            //         if(ret){
            //             if(ret.ret){
            //                 layer.msg(ret.ret)
            //                 window.location.reload()
            //             }else{
            //                 layer.msg(ret.err)
            //             }
            //         }else{
            //             swal_msg("错误",ret,"error");
            //         }
            //     })
            // });

            layer.prompt({
                formType: 2,
                title: '拒绝理由',
                btnAlign: 'c',
                yes: function(index, layero){
                    // 获取文本框输入的值
                    remark = layero.find(".layui-layer-input").val();

                    layer.close(index);

                    ajaxFun("post","{:url('update')}",{id:id,status:value,remark:remark},'json',function(ret){
                        if(ret){
                            if(ret.ret){
                                layer.msg(ret.ret)
                                window.location.reload()
                            }else{
                                layer.msg(ret.err)
                            }
                        }else{
                            swal_msg("错误",ret,"error");
                        }
                    })
                }
            });
        } else {
            ajaxFun("post","{:url('update')}",{id:id,status:value,remark:remark},'json',function(ret){
                if(ret){
                    if(ret.ret){
                        layer.msg(ret.ret)
                        window.location.reload()
                    }else{
                        layer.msg(ret.err)
                    }
                }else{
                    swal_msg("错误",ret,"error");
                }
            })
        }
    }

    function del(id) {
        swal_del(id, "{:url('del')}")
    }

    function member(id)
    {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("member/index")}?search=id&name='+id
            });
        });
    }
    function alla(types){
        var all=$(".form-horizontal").serialize();
        var alls=$(".form-horizontal").serializeArray();
       console.log(JSON.stringify(alls))

        ajaxFun("post",'{:url('shenheAll')}?status='+types,all,'json',function(ret){
            
            if(ret){
                swal_msg('操作成功')
                setTimeout(()=>{
                    window.location.reload()
                }, 1500)
            }
        })
         
    }

    function watch(id) {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("watch")}?id='+id
            });
        });
    }

    function setRealFace(id, state) {
        $.ajax({
            type: 'post',
            url: '{:url("setRealFace")}',
            data: {id, state},
            dataType: 'json',
            success:function(ret){
                if (ret.ret) {
                    let html = state ? `<span class="btn btn-xs btn-danger" onclick="setRealFace('${id}', 0)">取消真人</span>` : `<span class="btn btn-xs btn-primary" onclick="setRealFace('${id}', 1)">设置真人</span>`;
                    $('#real' + id).html(html)
                    layer.msg(ret.ret);
                } else {
                    layer.msg(ret.err);
                }

            },
            error:function(err){
                layer.msg(err)
            }
        });
    }
</script>
 